package net.wanho.service.impl;

import cn.hutool.core.lang.hash.Hash;
import lombok.RequiredArgsConstructor;
import net.wanho.constant.UserConstant;
import net.wanho.mapper.UserMapper;
import net.wanho.po.User;
import net.wanho.service.UserService;
import net.wanho.util.PwdUtil;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Author：汤小洋
 * Date：2023-10-13 13:48
 * Description：<描述>
 */
@Service
@RequiredArgsConstructor
@Transactional(rollbackFor = Exception.class)
public class UserServiceImpl implements UserService {

    private final UserMapper userMapper;

    @Override
    public void add(User user) {
        user.setPassword(PwdUtil.encrypt(user.getPassword()));
        user.setStatus(UserConstant.STATUS_ENABLE);
        userMapper.insert(user);
    }
}
